05. Lab I: Solution

Solution: Build a Dog REST API - Set Up

Below, we'll walk through each step of the lab and look at one potential way to implement the lab. Even if you get stuck, you should always first try to work through the lab without the solution before coming here, so that you can best learn the related skills and be ready for the project at the end of the course.

Step 1: Use Spring Initializr to bootstrap a simple project.

  • Add the H2 Database, Spring Web Starter, and the Spring Data JPA dependencies before generating the project.

Select the correct dependencies for the project

Select the correct dependencies for the project

Step 2: Set-up the H2 in-memory database.

  • Enable the console, add a path for the console, and create a url for the datasource using H2.

Within application.properties (found within /src/main/resources/), you could add the following code:

spring.h2.console.enabled=true
spring.h2.console.path=/h2

spring.datasource.url=jdbc:h2:mem:dogdata

Note that dogdata is just what I chose as the name - yours does not need to match this.